define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'unanswered/index',
        temperature1_url: 'form1/temperature_index',
        temperature3_url: 'form3/temperature_index',
        temperature5_url: 'form5/temperature_index',
        form8_index_url: 'form2/form8_index'
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh'],
                cols: [[
                    // {type: 'checkbox'},
                    {field: 'id', title: 'ID', width: 80},
                    {field: 'name', title: '姓名', width: 100},
                    {field: 'sex', search: 'select', selectList: ["男","女"], title: '性别', width: 80},
                    {field: 'id_card', title: '身份证', width: 180},
                    {field: 'mobile', title: '手机号', width: 150},
                    {field: 'arrival_time', title: '到沙时间', width: 160, search: 'range'},
                    {field: 'departure', title: '出发地', width: 160},
                    {field: 'check_time', title: '最近核酸检测', width: 160, search: 'range'},
                    {field: 'check_result', search: 'select', selectList: ["阴性","阳性"], title: '检测结果', width: 100, templet: function (d) {
                            if (d.check_result === 1) {
                                return '<div class="layui-table-cell" style="background-color: red;color: #fff;">阳性</div>';
                            }
                            return '<div class="layui-table-cell">阴性</div>';
                        }},
                    {field: 'community', title: '所属社区', selectList: getCommunityList, width: 150},
                    {field: 'status', title: '状态', selectList: ['未解除','已解除','已废弃'], width: 120, templet: function(d){
                            if (d.status === 1) {
                                return '<div class="layui-table-cell" style="background-color: green;color: #fff;">已解除</div>';
                            } else if (d.status === 2) {
                                return '<div class="layui-table-cell" style="background-color: #FFB800;color: #fff;">已废弃</div>';
                            } else {
                                return '<div class="layui-table-cell">未解除</div>';
                            }
                        }},
                    {field: 'count', title: '体温通知天数', width: 120, templet: function (d) {
                            return '<div class="layui-table-cell">' + d.count / 2 + '天</div>';
                        }
                    },
                    {field: 'sms_time', title: '最近通知时间', width: 160, templet: ea.table.date},
                    {field: 'create_time', title: '提交时间', width: 160, search: 'range'},
                    {
                        width: 180,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '体温记录',
                                url: init.temperature1_url,
                                method: 'open',
                                auth: 'temperature1',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                                extend: 'data-full="true"',
                                extra: 'name',
                            }]
                        ]
                        , fixed: 'right'
                    }
                ]],
            });

            ea.listen();
        },
        form3_index: function () {
            ea.table.render({
                init: {
                    table_elem: '#currentTable',
                    table_render_id: 'currentTableRenderId',
                    index_url: 'unanswered/form3_index',
                },
                toolbar: ['refresh'],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'ID', width: 100},
                    {field: 'name', title: '姓名'},
                    {field: 'id_card', title: '身份证号', width: 180},
                    {field: 'community', selectList: getCommunityList, title: '居住地所属社区'},
                    {field: 'buy_time', title: '购药时间'},
                    {field: 'mobile', title: '手机号'},
                    {field: 'status', title: '状态', selectList: ['未解除','已解除','已废弃'], templet: function(d){
                            if (d.status === 1) {
                                return '<div class="layui-table-cell" style="background-color: green;color: #fff;">已解除</div>';
                            } else if (d.status === 2) {
                                return '<div class="layui-table-cell" style="background-color: #FFB800;color: #fff;">已废弃</div>';
                            } else {
                                return '<div class="layui-table-cell">未解除</div>';
                            }
                        }},
                    {field: 'count', title: '体温通知天数', templet: function (d) {
                            return '<div class="layui-table-cell">' + d.count / 2 + '天</div>';
                        }
                    },
                    {field: 'sms_time', title: '最近通知时间', width: 160, templet: ea.table.date},
                    {field: 'create_time', title: '提交时间'},
                    {
                        width: 180,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '体温记录',
                                url: init.temperature3_url,
                                method: 'open',
                                auth: 'temperature3',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                                extend: 'data-full="true"',
                                extra: 'name',
                            }]
                        ]
                        , fixed: 'right'
                    }
                ]],
            });

            ea.listen();
        },
        form2_index: function () {
            ea.table.render({
                init: {
                    table_elem: '#currentTable',
                    table_render_id: 'currentTableRenderId',
                    index_url: 'unanswered/form2_index',
                },
                toolbar: ['refresh'],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'ID', width: 100},
                    {field: 'name', title: '姓名'},
                    {field: 'id_card', title: '身份证号'},
                    {field: 'community', selectList: getCommunityList, title: '居住地所属社区'},
                    {field: 'vaccination_time', title: '接种时间'},
                    {field: 'dosage', search: 'select', selectList: ["无","第1剂","第2剂","第三剂"], title: '接种剂次'},
                    {field: 'mobile', title: '手机号'},
                    {field: 'status', title: '状态', selectList: ['未解除','已解除','已废弃'], width: 120, templet: function(d){
                            if (d.status === 1) {
                                return '<div class="layui-table-cell" style="background-color: green;color: #fff;">已解除</div>';
                            } else if (d.status === 2) {
                                return '<div class="layui-table-cell" style="background-color: #FFB800;color: #fff;">已废弃</div>';
                            } else {
                                return '<div class="layui-table-cell">未解除</div>';
                            }
                        }},
                    {field: 'count', title: '体温通知天数', width: 120, templet: function (d) {
                            return '<div class="layui-table-cell">' + d.count / 2 + '天</div>';
                        }
                    },
                    {field: 'sms_time', title: '最近通知时间', width: 160, templet: ea.table.date},
                    {field: 'create_time', title: '创建时间'},
                    {
                        width: 180,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '异常记录',
                                url: init.form8_index_url,
                                method: 'open',
                                auth: 'form8',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                                extend: 'data-full="true"',
                                extra: 'name',
                            }]
                        ]
                        , fixed: 'right'
                    }
                ]],
            });

            ea.listen();
        },
        form5_index: function () {
            ea.table.render({
                init: {
                    table_elem: '#currentTable',
                    table_render_id: 'currentTableRenderId',
                    index_url: 'unanswered/form5_index',
                },
                toolbar: ['refresh'],
                cols: [[
                    {field: 'id', title: 'ID', width: 80},
                    {field: 'name', title: '姓名'},
                    {field: 'sex', search: 'select', selectList: ["男","女"], title: '性别', width: 80},
                    {field: 'id_card', title: '身份证号', width: 180},
                    // {field: 'buy_way', title: '行程出发地、路径地及时间'},
                    {field: 'mobile', title: '手机号', width: 150},
                    {field: 'departure', title: '出发地', width: 160},
                    {field: 'community', selectList: getCommunityList, title: '去向', width: 160},
                    // {field: 'living', title: '现居住地址'},
                    // {field: 'employer', title: '工作单位'},
                    {field: 'arrival_time', title: '到沙时间', width: 160},
                    // {field: 'observe', title: '留观点'},
                    {field: 'is_danger_location', search: 'select', selectList: ["否","是"], title: '高中风险地区', width: 150, templet: function (d) {
                            if (d.is_danger_location) {
                                return '<div class="layui-table-cell" style="background-color: red;color: #fff;">是</div>';
                            }
                            return '<div class="layui-table-cell">否</div>';
                        }},
                    // {field: 'person_type', title: '人员类别'},
                    // {field: 'desc', title: '备注'},
                    {field: 'jc_time', title: '预计解除隔离时间', width: 160},
                    {field: 'status', title: '状态', selectList: ['未解除','已解除','已废弃'], width: 120, templet: function(d){
                            if (d.status === 1) {
                                return '<div class="layui-table-cell" style="background-color: green;color: #fff;">已解除</div>';
                            } else if (d.status === 2) {
                                return '<div class="layui-table-cell" style="background-color: #FFB800;color: #fff;">已废弃</div>';
                            } else {
                                return '<div class="layui-table-cell">未解除</div>';
                            }
                        }},
                    {field: 'count', title: '体温通知天数', width: 120, templet: function (d) {
                            return '<div class="layui-table-cell">' + d.count / 2 + '天</div>';
                        }
                    },
                    {field: 'sms_time', title: '最近通知时间', width: 160, templet: ea.table.date},
                    {field: 'create_time', title: '提交时间', width: 160},
                    {
                        width: 180,
                        title: '操作',
                        templet: ea.table.tool,
                        operat: [
                            [{
                                text: '体温记录',
                                url: init.temperature5_url,
                                method: 'open',
                                auth: 'temperature',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                                extend: 'data-full="true"'
                            }]
                        ]
                        , fixed: 'right'
                    }
                ]],
            });

            ea.listen();
        },
    };
    return Controller;
});